package com.drinks.yiniang.adapter.user.friends;

import android.content.Context;
import android.support.annotation.Nullable;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseViewHolder;
import com.drinks.yiniang.R;
import com.drinks.yiniang.adapter.base.BaseQuickRCVAdapter;
import com.drinks.yiniang.entity.user.friends.FriendsJson;
import com.drinks.yiniang.utils.GlideUtils;
import com.hansen.library.Constants;
import com.hansen.library.ui.widget.image.CircleImageView;

import java.util.List;

/**
 * 好友列表adapter
 * @author han
 * @date 2019/8/30
 */
public class FriendsListAdapter extends BaseQuickRCVAdapter<FriendsJson.FriendsList, BaseViewHolder> {

    private TextView tvFollow;

    private String mFriendsType;

    public FriendsListAdapter(Context mContext, @Nullable List<FriendsJson.FriendsList> data) {
        super(R.layout.item_friends_list, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, FriendsJson.FriendsList item) {
        GlideUtils.loadAvatar(mContext, (CircleImageView) helper.getView(R.id.iv_friends_ls_avatar), item.getFans_avatar());
        helper.setText(R.id.tv_friends_ls_nickname, item.getFans_username());

        tvFollow = helper.getView(R.id.tv_friends_ls_follow);

        if(Constants.TYPE_FRIENDS_FANS.equals(mFriendsType)) {//我的粉丝
            if(Constants.STATUS_FOLLOW_EACH_OTHER.equals(item.getStatus())) {
                tvFollow.setSelected(true);
                helper.setText(R.id.tv_friends_ls_follow, mContext.getString(R.string.text_follow_each_other));
            } else {
                tvFollow.setSelected(false);
                helper.setText(R.id.tv_friends_ls_follow, mContext.getString(R.string.text_follow_him));
            }
        } else {//我的关注
            tvFollow.setSelected(true);
            tvFollow.setText(mContext.getString(R.string.text_already_follow));
        }

        helper.addOnClickListener(R.id.tv_friends_ls_follow);
    }

    public void setFriendsType(String friendsType) {
        this.mFriendsType = friendsType;
    }
}
